package liurong.driver.sort;

import com.alibaba.fastjson.JSON;

public class Sort {
	public static void main(String[] args) {
		popSort();
	}

	// 冒泡排序
	public static void popSort() {
		int[] arr = { 9, 6, 4, 7, 1, 3, 2, 8 };
		System.out.println("排序前：" + JSON.toJSONString(arr));

		int temp = 0;
		for (int i = 0; i < arr.length; i++) {
			for (int j = i + 1; j < arr.length; j++) {
				if (arr[i] > arr[j]) {
					temp = arr[i];
					arr[i] = arr[j];
					arr[j] = temp;
				}
			}
		}

		System.out.println("排序后：" + JSON.toJSONString(arr));
	}
}
